<!--********************************************************************
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title data-i18n="resources.title_markerLayer"></title>
    <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
    <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
    <style type="text/css">
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%
        }

        #map {
            position: absolute;
            width: 100%;
            height: 100%;
            border: 1px solid #3473b7;
        }
    </style>
</head>
<body>
<div id="map"></div>
<script>
    var map, layer, markerlayer, marker,
        host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090",
        url = host + "/iserver/services/map-world/rest/maps/World";

    init();
    function init() {
        map = new SuperMap.Map("map", {
            controls: [
                new SuperMap.Control.Zoom(),
                new SuperMap.Control.Navigation(),
                new SuperMap.Control.LayerSwitcher()
            ]
        });
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, null, {maxResolution: "auto"});
        layer.events.on({"layerInitialized": addLayer});
        markerlayer = new SuperMap.Layer.Markers("markerLayer");
        addData();
    }

    function addLayer() {

        map.addLayers([layer, markerlayer]);
        //显示地图范围
        map.setCenter(new SuperMap.LonLat(106.3, 39.9), 2);

    }

    //添加数据
    function addData() {
        markerlayer.removeMarker(marker);
        var size = new SuperMap.Size(44, 33);
        var offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
        var icon = new SuperMap.Icon('./images/marker.png', size, offset);
        marker = new SuperMap.Marker(new SuperMap.LonLat(116.3, 39.9), icon);
        markerlayer.addMarker(marker);
    }
</script>

</body>
</html>